package com.fenxiangtech.mall.web.controller.v1;

import com.fenxiangtech.mall.service.UserTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author zhangjiashun
 */
@Controller("tokenControllerV1")
@RequestMapping("/v1/token")
public class TokenController {

    @Autowired
    private UserTokenService userTokenService;

    @PostMapping("/user")
    @ResponseBody
    public Map<String, String> getToken(@RequestBody Map<String, String> requestDate) {
        return userTokenService.getToken(requestDate.get("code"));
    }

    @PostMapping("/verify")
    @ResponseBody
    public void verifyToken() {
        UserTokenService userTokenService = this.userTokenService;
        userTokenService.verifyToken();
    }
}
